import en from "../i18n/lang/en"
import Vue from "vue"
import Router from "vue-router"
import CommerViews from "@/views/commerViews"
import Login from "@/views/login/index"
import Register from "@/views/register/register"
import Layout from "@/views/layout/layout"
import HomeMain from "@/views/index/mainIndex"
import Orders from "@/views/Orders/Orders"
import myReport from "@/views/upload/myReport"
// import reportDetail from "@/views/upload/reportDetail"
// 不是必须加载的组件使用懒加载

const DataTable = () => import("@/views/table/dataTables")
const reportDetail = () => import("@/views/upload/reportDetail")
const Upload = () => import("@/views/upload/upload")

const NotFound = () => import("@/views/page404")

const NavClassify = () => import("@/views/syssetting/navClassify")
const pagePermissions = () => import("@/views/permissions/pagePermissions")
const ForgotPwd = () => import("@/views/forgotPassword/forgotPassword")

/**
 * 重写路由的push方法
 */
const routerPush = Router.prototype.push
Router.prototype.push = function push (location) {
  return routerPush.call(this, location).catch(error => error)
}
Vue.use(Router)
let routeName = en.routeName
let defaultRouter = [
  { path: "/", redirect: "/index", hidden: true, children: [] },
  {
    path: "/login",
    component: Login,
    name: "",
    hidden: true,
    children: []
  },
  {
    path: "/register",
    hidden: true,
    component: Register,
    children: []
  },
  {
    path: "/forgotPwd",
    hidden: true,
    component: ForgotPwd,
    children: []
  },
  {
    path: "/index",
    iconCls: "fa fa-dashboard", // 图标样式class
    name: routeName.home,
    component: Layout,
    alone: true,
    children: [
      {
        path: "/index",
        iconCls: "fa fa-dashboard", // 图标样式class
        name: "主页",
        component: HomeMain,
        children: []
      }
    ]
  },

  {
    path: "/404",
    component: NotFound,
    name: "404",
    hidden: true,
    children: []
  }
]

let addRouter = [
  // {
  //   path: "/",
  //   iconCls: "fa fa-newspaper-o", // 图标样式class
  //   name: routeName.table,
  //   component: Layout,
  //   children: [
  //     {
  //       path: "/dataTable",
  //       iconCls: "fa fa-sliders", // 图标样式class
  //       name: routeName.multiDataTable,
  //       component: DataTable,
  //       children: []
  //     },
  //     {
  //       path: "/order",
  //       iconCls: "el-icon-edit-outline", // 图标样式class
  //       component: Orders,
  //       name: routeName.orders,
  //       children: []
  //     }
  //   ]
  // },

  {
    path: "/",
    iconCls: "el-icon-s-management", // 图标样式class
    name: routeName.upload,
    component: Layout,
    meta: { role: ["superAdmin"] },
    children: [
      {
        path: "/upload",
        iconCls: "el-icon-upload2", // 图标样式class
        name: routeName.fileUpload,
        component: Upload,
        children: []
      },
      {
        path: "/myreport",
        iconCls: "el-icon-document-copy", // 图标样式class
        name: routeName.myreport,
        component: myReport,
        children: []
      },
      {
        path: "/reportdetail",
        iconCls: "el-icon-document-copy", // 图标样式class
        name: routeName.reportDetail,
        component: reportDetail,
        children: []
      }
    ]
  },
  // {
  //   path: "/",
  //   iconCls: "fa fa-universal-access", // 图标样式class
  //   name: routeName.permissions,
  //   component: Layout,
  //   children: [
  //     {
  //       path: "/pagePermissions",
  //       iconCls: "fa fa-expeditedssl", // 图标样式class
  //       name: routeName.pageControl,
  //       component: pagePermissions,
  //       children: []
  //     }
  //     // {
  //     //   path: "/btnPermissions",
  //     //   iconCls: "fa fa-toggle-on", // 图标样式class
  //     //   name: routeName.btnControl,
  //     //   component: btnPermissions,
  //     //   children: []
  //     // }
  //   ]
  // },

  // {
  //   path: "/",
  //   iconCls: "el-icon-setting", // 图标样式class
  //   name: routeName.systemSettings,
  //   component: Layout,
  //   meta: { role: ["superAdmin"] },
  //   children: [
  //     {
  //       path: "/navClassifies",
  //       iconCls: "el-icon-menu", // 图标样式class
  //       name: routeName.navMenu,
  //       component: NavClassify,
  //       children: []
  //     }
  //   ]
  // },
  { path: "*", redirect: "/404", hidden: true, children: [] }
]
export default new Router({
  routes: defaultRouter
})
export { defaultRouter, addRouter }
